<?php

function objectToArray($object, $arr=array()) {
	
	$indices = get_object_vars($object);
	
	foreach($indices as $i => $indice) {
		
		$arr[$i] = array();
		
		foreach($indice as $j => $object) {
	
			if(is_object($object)) {
				$arr[$i][$j] = get_object_vars($object);
			}
			else {
				$arr[$i][$j] = $object;
			}
			
		}
		
	}
	return $arr;
}
